home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / dsp / 96000tar.z / 96000tar / 96000 / appb / b122.asm < prev    next >
Assembly Source File  |  1992-04-28  |  4KB  |  76 lines

  1. ; This program was originally published in the Motorola DSP96002 Users Manual
  2. ; and is provided under a DISCLAIMER OF WARRANTY available from Motorola DSP
  3. ; Operation, 6501 William Cannon Drive West, Austin, Texas 78735-8598.  For
  4. ; more information, refer to the DSP96002 Users Manual, Appendix B, DSP
  5. ; Benchmarks.
  6. ;
  7. ; B.1.22     NxN  NxN  Matrix Multiply  
  8. ;The matrix multiplications are for square NxN matrices. All the elements  are stored in "row major" for-
  9. ;mat. i.e. for the array A:  
  10. ;   a(1,1) ... a(1,N) 
  11. ;                                          a(N,1) ... a(N,N) 
  12. ;
  13. ;the elements are stored:  
  14. ;a(1,1), a(1,2), ..., a(1,N), a(2,1), a(2,2), ..., a(2,N), ... 
  15. ;
  16. ;The following code implements C=AB where A and B are square matrices.  
  17. ;
  18. ;                                      DSP56000 IMPLEMENTATION 
  19. ;                                                           Program     ICycles
  20. ;                                                            Words 
  21. ; move   #mat_a,r0                 ;point to A             1        1 
  22. ; move   #mat_b,r4                 ;point to B             1        1 
  23. ; move   #mat_c,r6                 ;output mat C           1        1 
  24. ; move   #N,n0                     ;array size             1        1 
  25. ; move   n0,n5                                             1        1 
  26. ; do     #N,_rows                  ;do rows                2        3 
  27. ; do     #N,_cols                  ;do columns             2        3 
  28. ; move   r0,r1                     ;copy start of row A    1        1 
  29. ; move   r4,r5                     ;copy start of col B    1        1 
  30. ; clr    a                         ;clear sum and pipe     1        1 
  31. ; move             x:(r1)+,x0 y:(r5)+n5,y0                 1        1 
  32. ; rep    #N-1                      ;sum                    1        1 
  33. ; mac    x0,y0,a   x:(r1)+,x0 y:(r5)+n5,y0                 1        2 
  34. ; macr   x0,y0,a   (r4)+           ;finish, next column B  1        1 
  35. ; move   a,y:(r6)+                 ;save output            1        1 
  36. ;_ecols 
  37. ;; move   (r0)+n0                   ;next row A             1        1 
  38. ; move   #mat_b,r4                 ;first element B        1        1 
  39. ;_erows 
  40. ;                                                        -----    ----- 
  41. ;                                                         19          
  42. ;                               ((8+(N-1))N+5)N+8 = N3 +7*N2 +5N+8  ? 
  43. ;At a DSP56000/1 clock speed of 20.5 MHz, a [10x10][10x10] can be computed in .1715 ms.
  44. ;
  45. ;                                             DSP96002 IMPLEMENTATION 
  46. ;                                                            Program    ICycles 
  47. ;                                                            Words 
  48.    move   #mat_a,r0                 ;point to A              1        1 
  49.    move   #mat_c,r6                 ;output mat C            1        1 
  50.    move   #N,n0                     ;array size              1        1 
  51.    move   n0,n5                                              1        1 
  52.  
  53.    do     #N,_rows                                      ;    2        3 
  54.    move   #mat_b,r4                 ;point to B              1        1 
  55.    move   r0,r1                     ;copy start of row       1        1 
  56.    do     #N,_cols                                      ;    2        3 
  57.    move                         r4,r5                   ;    1        1 
  58.    fclr   d0                    (r4)+                   ;    1        1 
  59.    fclr   d1                    x:(r1)+,d4.s y:(r5)+n5,d5.s ;1        1 
  60.    rep    #N                                                ;1        2 
  61.    fmpy   d4,d5,d1 fadd.s d1,d0 x:(r1)+,d4.s y:(r5)+n5,d5.s ;1        1 
  62.                    fadd.s d1,d0 r0,r1                       ;1        1 
  63.    move                                     d0.s,y:(r6)+    ;1        1 
  64. _cols 
  65.    move                         (r0)+n0                     ;1        1 
  66. _rows 
  67. ;                                                         ; -----    ----- 
  68. ;                                             Totals:       19          
  69.                                                                        
  70. ;                                                ((N+7)N+6)N+7 = N3 +7*N2 +6N+7 ?
  71. ; At a DSP96002 clock speed of 26.66 MHz, a [10x10][10x10] can be computed in .1325 ms.
  72.